package com.leadnews.mapper;

import com.leadnews.pojo.MessageDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leadnews.vo.MessageDetailVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author 自己
 * @description 针对表【message_detail】的数据库操作Mapper
 * @createDate 2023-01-25 10:53:57
 * @Entity com.leadnews.pojo.MessageDetailVo
 */
public interface MessageDetailMapper extends BaseMapper<MessageDetail> {

    @Select("SELECT md.*,i1.sp,i2.rp from message_detail md,(select name name1,picture sp from level where name in " +
            "(SELECT sender from message_detail  where message_id in (SELECT id FROM message where user_id=#{id1} or receiver=#{id1} and id=#{id}))) i1,(select name name2,picture rp from level where name in " +
            "(SELECT receiver from message_detail  where message_id in (SELECT id FROM message where user_id=#{id1} or receiver=#{id1} and id=#{id}))) i2 where md.message_id in " +
            "(SELECT id FROM message where (user_id=#{id1} or receiver=#{id1}) and id=#{id}) and i1.name1=md.sender and i2.name2=md.receiver")
    List<MessageDetailVo> findById(@Param("id") Integer id, @Param("id1") Object id1);
}




